package com.elm.controller;

import com.elm.po.Food;
import com.elm.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/food")
public class FoodController {
    @Autowired
    private FoodService foodService;

    @GetMapping("/getFoodByBusinessId")
    public List<Food> listFoodByBusinessId(@PathVariable Integer businessId) {
        return foodService.getFoodByBusinessId(businessId);
    }

    @GetMapping("/getAllReviewingFood")
    public List<Food> getAllReviewingFood() {
        return foodService.getAllReviewingFood();
    }

    @PutMapping("/updateReviewingBusinessInfo")
    public Integer updateReviewingBusinessInfo(@PathVariable Integer foodId, 
                             @RequestParam boolean result,
                             @RequestParam String userId) {
        return foodService.updateReviewingBusinessInfo(foodId, result);
    }

    @PutMapping("/updateFoodInfo")
    public Integer updateFoodInfo(@RequestBody Food food) {
        return foodService.updateFoodInfo(food);
    }

    @PostMapping("/createFood")
    public Integer createFood(@RequestBody Food food) {
        return foodService.createFood(food);
    }

    @PutMapping("/updateFoodStatus")
    public Integer updateFoodStatus(@RequestBody Food food) {
        return foodService.updateFoodStatus(food);
    }
}